/*#include <stdio.h>
#include <stdlib.h>

typedef struct link {
    int data;
    struct link* next;
} * Link;//已经定义成指针，后面函数里便不用*

Link Create(int n);
void Display(Link head);

int main() {
    int n;
    Link head;
    scanf("%d", &n);
    head = Create(n);
    Display(head);
    return 0;
}

Link Create(int n) {
    if (n <= 0) {
        return NULL;
    }

    Link head = (Link)malloc(sizeof(struct link));
	//(sizeof(struct link))而不是malloc(sizeof(Link))，Link是指针，而(sizeof(struct link))才是新节点的内存大小
    Link current = head;
    for (int i = 0; i < n; ++i) 
	{
        scanf("%d", &current->data);
        current->next = (i == n - 1) ? NULL : (Link)malloc(sizeof(struct link));
        current = current->next;
    }
    return head;
}

void Display(Link head) {
    if (head == NULL) {
        printf("NULL\n");
        return;
    }

    while (head != NULL) {
        printf("%d", head->data);

        if (head->next != NULL) {
            printf("->");
        } else {
            printf("\n");
        }

        head = head->next;
    }
}
*/
#include <stdio.h>
#include <stdlib.h>

typedef struct link
{
    int data;
    struct link *next;
}*Link;

Link Create(int n);
void Display(Link head);
void Search(Link head,int num);
void Delete(Link *head,int num);
void Clear(Link *head);
int main()
{
    int   n;
    Link  head;
    scanf("%d",&n);
    head = Create(n);
    Display(head);
    int num_t;
    scanf("%d",&num_t);\
    Search(head,num_t);
    Delete(&head,num_t);
    Display(head);
    Clear(&head);
	Display(head);
    return 0;
}

/*在此实现 Create函数 */
Link Create(int n)
{
    Link new_node,tail,head;
    head=NULL;
    for(int i=1;i<=n;i++)
    {
    	new_node=(Link)malloc(sizeof(struct link));
        scanf("%d",&new_node->data);
        new_node->next=NULL;
        tail=head;
        if(tail!=NULL)
        {
            while(tail->next)
            {
                tail=tail->next;
            }
            tail->next=new_node;
        }
        else
            head=new_node;
    }
    return head;
}
/*在此实现Display函数 */
void Display(Link head)
{
    if(head==NULL)
        printf("NULL\n");
    else
    {
        for(Link new_node=head;new_node;new_node=new_node->next)
        {
            if(new_node==head)
                printf("%d",new_node->data);
            else
                printf("->%d",new_node->data);
        }
        printf("\n");
    }
}
void Search(Link head,int num)
{
	int IsFound=0;
	for(Link new_node=head;new_node;new_node=new_node->next)
	{
		if(new_node->data==num)
		{
			IsFound=1;
			printf("%d is found.\n",num);
			break;
		}
	}
	if(!IsFound)
		printf("%d isn't found.\n",num);
}
void Delete(Link *head,int num)
{
	int IsFound=0;
	for(Link p=*head,q=NULL;p;q=p,p=p->next)
	{	
		if(p->data==num)
		{
			IsFound=1;
			if(q)
				q->next=p->next;	
			else
				*head=p->next;   
			free(p);
			break;
		}
	}
	if(!IsFound)
		printf("%d isn't found.\n",num);
}
void Clear(Link *head)
{
	Link p = *head, q = NULL;
	while (p)
	{
    	q = p;
    	p = p->next;
    	free(q);
	}
	*head = NULL;
}